//
//  HKViewController.m
//  HKLibDatePicker
//
//  Created by HJT916109796 on 01/21/2021.
//  Copyright (c) 2021 HJT916109796. All rights reserved.
//

#import "HKViewController.h"
#import <HKLibDatePicker/HKDatePicker.h>
#import <HKLibCommon/HKPrefixHeader.h>
@interface HKViewController ()<UITableViewDelegate,UITableViewDataSource>
/// TableView
@property (nonatomic, strong) UITableView * tableView ;
/// 数据源
@property (nonatomic, strong) NSMutableArray * dataArray ;
@end

@implementation HKViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    self.dataArray = @[@"年月日选择",@"年月选择"].mutableCopy;
    _tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
    _tableView.backgroundColor = [UIColor whiteColor];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [self.view addSubview:_tableView];
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.textLabel.text = self.dataArray[indexPath.row];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [self datePicker];
}
- (void)datePicker {
    HKDatePicker * datePicker = [[HKDatePicker alloc] initWithTitle:@"请选择年月日" dateType:UIDatePickerModeDate defaultSelValue:nil minDateStr:@"1900-08-28 00:00:00" maxDateStr:@"2025-05-05 00:00:00" isAutoSelect:YES];
    datePicker.resultBlock = ^(NSString *selectValue) {
        [HKKeyWindow hk_toast:selectValue];
    };
    [datePicker showWithAnimation:YES];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
